package com.puff.jdbc.core;

import java.util.HashMap;
import java.util.Map;

import com.puff.jdbc.statement.SqlStatement;

/**
 * 
 * @author dongchao
 *
 */
public enum SqlStatementMapping {
	INSTANCE;

	private Map<String, SqlStatement> statementMapping = new HashMap<String, SqlStatement>();

	public void put(String key, SqlStatement statement) {
		if (statementMapping.get(key) != null) {
			throw new RuntimeException("SQLID:" + key + "is already exits");
		}
		statementMapping.put(key, statement);
	}

	public SqlStatement get(String key) {
		SqlStatement statement = statementMapping.get(key);
		if (statement == null) {
			throw new NullPointerException("SQLID:" + key + "not exits");
		}
		return statement;
	}

}
